package client.comm.baoding.dialog

import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.ObservableField
import client.comm.baoding.R
import client.comm.baoding.api.bean.UserAddress
import client.comm.baoding.databinding.LayoutJyinputnumAddressBinding
import client.comm.baoding.databinding.LayoutJyinputnumBinding
import client.comm.baoding.ui.AddrMangerActivity
import client.comm.baoding.ui.vm.TradeDetailModel
import client.tzstore.oo.dialog.CenterDialog

open class JyInputNumWithAddressDialog(context: Context, var type: Int) :
    CenterDialog<LayoutJyinputnumAddressBinding>(context) {

    var okTxt: String = "确定"
    var cancleTxt: String = "取消"
    var cancle: (() -> Unit)? = null
    var ok: ((num: String) -> Unit)? = null

    var onSelectAddress: (() -> Unit)? = null

    val num = ObservableField<String>("")

    val uAddress = ObservableField<UserAddress>()

    fun okClick() {
        ok?.invoke(num.get()!!)
    }

    fun cancleClick() {
        cancle?.apply {
            this()
        }
        cancel()
    }

    fun selectAddr() {
        onSelectAddress?.invoke()
    }

    override fun getV(): Int {
        return R.layout.layout_jyinputnum_address
    }

    override fun postBinding() {
        binding.event = this
        var title = when (type) {
            1 -> "购买"
            2 -> "提货"
            3 -> "摘单"
            4 -> context.getString(R.string.aixin_xs)
            5 -> "退款"
            else -> ""
        }
        binding.title = title

    }

}